package com.lyn.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.viewbinding.ViewBinding;

/**
 * @author longyn 2023/10/10
 * @version 1.0.0
 */
public abstract class BaseFragment <V extends ViewBinding> extends Fragment {

    public V binding;

    public abstract V getViewBinding(@NonNull LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup);

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        try {
            binding = getViewBinding(inflater,container);
            return binding.getRoot();
        }finally {
            onInitView();
        }
    }

    public abstract void onInitView();

}
